export const resolveSearch = search => {
    search = search || window.location.search;
    const dummyAndValues = search.split('?');
    let values;
    if (dummyAndValues.length <= 1) {
        values = dummyAndValues[0];
    } else {
        values = dummyAndValues[1];
    }
    const valueArr = values.split('&');
    const res = {};
    for (const valuePair of valueArr) {
        if (!valueArr) {
            continue;
        }
        const pair = valuePair.split('=');
        if (pair.length !== 2) {
            console.warn('Invalidate pair:', pair);
            continue;
        }
        const name = pair[0];
        const value = pair[1];
        if (name in res) {
            let arr;
            if ((typeof res[name]) === 'string') {
                arr = [res[name]];
            } else {
                arr = res[name];
            }
            arr.push(value);
        } else {
            res[name] = value;
        }
    }
    return res;
};